from typing import TypeVar


_T = TypeVar("_T")


def L(lst: list[_T], left=0, right=-1, copy=True) -> list[_T]:
    def positive_index(index: int) -> int:
        return index if index >= 0 else len(lst) + index

    if copy:
        lst = lst[:]

    left = positive_index(left)
    right = positive_index(right)

    if left >= right:
        return lst

    lst[left], lst[right] = lst[right], lst[left]
    return L(lst, left + 1, right - 1, copy=False)
